package com.itheima.spring.context;

import com.itheima.spring.beans.BeanDefinitionRegistry;

/**
 *  xml的bean定义读取器
 */
public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {

    public XmlBeanDefinitionReader(BeanDefinitionRegistry registry) {
        super(registry);
    }

    //从Resource中加载bean定义
    @Override
    public void loadBeanDefintions(Resource resource) throws Throwable {
        this.loadBeanDefintions(new Resource[]{resource});
    }

    @Override
    public void loadBeanDefintions(Resource... resource) throws Throwable {
        if(resource != null && resource.length>0){
            for (Resource r: resource){
                this.parseXml(r);
            }
        }
    }

    //解析XML,bean定义
    private void parseXml(Resource resource){
        // TODO 解析xml文档，获取bean定义 ，创建bean定义对象，注册到BeanDefinitionRegistry中。
    }
}
